$(function(){
    bindingAction(); 
});

function bindingAction() {
	var subnavi = $("#subnavi");
	var left0 = subnavi.position().left;
	var top = subnavi.position().top;
	var rite0 = left0 + subnavi.width()+2;
	var bottom = top + subnavi.height()+2;
	var height = subnavi.height();
	
	$("#subnavi ul li").each(function(index) {
		$(this).hover(function(ind){
			left = $(this).position().left;
			var ele = $(this).find(".childli").eq(0);
			ele.css("position","absolute");
			ele.css("display","block");
//			ele.css("right",rite0);
			ele.css("top",height+4);
			ritePos = left+ele.width()
			if(ritePos < rite0)ele.css("left",0);
			else ele.css("right",0);
;
		});
		$(this).mouseleave(function(ind){
			$(this).find(".childli").eq(0).css("display","none");
		});

	});
	
}